﻿using UnityEngine;
using UnityEditor;

namespace Super
{
	public class AssetMenuExtension : EditorWindow
	{
		public static bool CheckIfSelectObject()
		{
			bool isNull = Selection.activeObject == null;
			if (isNull) return false;

			bool isNonDefaultAsset = Selection.activeObject.GetType() != typeof(DefaultAsset);
			if (isNonDefaultAsset) return true;

			return false;
		}

		[MenuItem("Assets/Create/Super/TemplateManager", true)]
		public static bool CheckIfSelectNoObject()
		{
			bool isNull = Selection.activeObject == null;
			if (isNull) return true;

			bool isDefaultAsset = Selection.activeObject.GetType() == typeof(DefaultAsset);
			if (isDefaultAsset) return true;

			return false;
		}

		[MenuItem("Assets/Create/Super/TemplateManager", false, 0)]
		public static void CreateTemplateSingleManager()
		{
			string path = AssetDatabase.GetAssetPath(AssetSettingSO.Ins.templateSingleManager);
			ProjectWindowUtil.CreateScriptAssetFromTemplateFile(path, "TemplateManager.cs");
			Debug.Log("TemplateManager文件创建成功");
		}
	}
}
